Skip to content

Add GitHub workflow to publish samples using latest NuGet version#3570

Draft
Copilot wants to merge 8 commits intomainfrom
copilot/add-github-workflow-for-samples
Draft

Add GitHub workflow to publish samples using latest NuGet version#3570
Copilot wants to merge 8 commits intomainfrom
copilot/add-github-workflow-for-samples

Conversation

Copy link
Contributor

Copilot AI commented Mar 23, 2026

Adds a new GitHub Actions workflow (.github/workflows/samples.yml) that automatically generates and publishes SkiaSharp samples to a dedicated docs-samples branch.

Description of Change

  • Triggers on push, pull_request, release (published), and workflow_dispatch
  • Path filters cover both samples/** and .github/workflows/samples.yml
  • workflow_dispatch inputs: version (NuGet version to use), sha (git SHA to build from), dry_run (skip push)
  • Fetches the latest SkiaSharp and HarfBuzzSharp versions from NuGet.org and updates scripts/VERSIONS.txt before generating
  • Generates samples via dotnet cake --target=samples-generate
  • Publishes to the docs-samples branch by cloning the existing branch (or initialising a fresh one), rsyncing generated output, and committing — preserving full history without force-pushing
  • Dry-run mode (triggered automatically on PRs or via the dry_run input): runs the full clone/rsync/git add/git commit --allow-empty sequence, then skips the push and prints git show --stat HEAD so the diff can be reviewed

Bugs Fixed

None.

API Changes

None.

Behavioral Changes

None.

Required skia PR

None.

PR Checklist

  • Has tests (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Merged related skia PRs
  • Changes adhere to coding standard
  • Updated documentation
Original prompt

I have a cake target sample that creates a zip of the samples in the repo. I want to create a new GitHub workflow that will run if anything in the samples dir is changed and run the cake target, but it must lt use the version number of the latest nuget preview or stable. The cake target basically removes the project references and replaces it with nuget references. Can you open a PR with a workflow that will basically push these samples to a new branch.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI changed the title [WIP] Add GitHub workflow to run Cake target on samples changes Add GitHub workflow to publish samples using latest NuGet version Mar 23, 2026
Copilot AI requested a review from mattleibow March 23, 2026 23:39
@mattleibow
Copy link
Contributor

@copilot i wa to always commit to the same samples branch. Also, can you add a parameter to pick the git sha for the sample to use. Also also I want to trigger on a release. Don't force push, just add a new commit.

… force push

Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mono/SkiaSharp/sessions/7df4a82e-892a-4246-a50f-bdf62b51d869
Copy link
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot i wa to always commit to the same samples branch. Also, can you add a parameter to pick the git sha for the sample to use. Also also I want to trigger on a release. Don't force push, just add...

Done in caadc2e. Here's what changed:

  • Fixed branch — always pushes to samples instead of a versioned branch
  • sha input — added to workflow_dispatch; the checkout step uses ref: ${{ inputs.sha || github.sha }}
  • Release trigger — added release: [published]
  • No force push — the publish step now clones the existing samples branch (or inits a new one), rsyncs the generated output over it, and pushes a regular commit, preserving history

@mattleibow
Copy link
Contributor

@copilot please add a dry run support if triggers by PR so we can test. Do everything except the push.

Copy link
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot please add a dry run support if triggers by PR so we can test. Do everything except the push.

Done in 990137c. Two ways to trigger a dry run:

  1. Open a PR that touches samples/** — the new pull_request trigger fires automatically and the publish step skips the push, listing all generated files instead.
  2. workflow_dispatch — a new dry_run boolean input lets you run manually without pushing.

In both cases everything up to and including dotnet cake --target=samples-generate executes normally; only the final git push is skipped.

@mattleibow
Copy link
Contributor

@copilot we also need to run this if a PR touches this workflow file. Same with a push. If this file or a sample changes

Copy link
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot we also need to run this if a PR touches this workflow file. Same with a push. If this file or a sample changes

Done in 0086bd7. Both push and pull_request triggers now include .github/workflows/samples.yml in their path filters alongside samples/**.

Removed 'develop' and 'release/**' branches from workflow triggers.
@mattleibow
Copy link
Contributor

@copilot i currently have a samples branch for some other work. Please update the workflow to use docs-samples for now

Copy link
Contributor Author

Copilot AI commented Mar 24, 2026

@copilot i currently have a samples branch for some other work. Please update the workflow to use docs-samples for now

Done in 4a0177fBRANCH_NAME is now docs-samples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants